<?php
/**
 * Created by PhpStorm.
 * User: 29620
 * Date: 2021/10/21
 * Time: 15:46
 */
namespace app\admin\model;

use think\Model;

class Order extends Model
{

    public function searchOrderSnAttr($q,$v,$d)
    {
        $q->where('order_sn','like','%'.$v.'%');
    }

    public function searchAddTimeAttr($q,$v,$d)
    {
        $q->where('addtime','>= TIME',$v);
    }

    public function searchAddTimesAttr($q,$v,$d)
    {
        $q->where('addtime','<= TIME',$v);
    }

    public function searchDPriceAttr($q,$v,$d)
    {
        $q->where('price','>=',$v);
    }

    public function searchGPriceAttr($q,$v,$d)
    {
        $q->where('price','<=',$v);
    }

    public function searchCidAttr($q,$v,$d)
    {
        $q->where('status','in',$v);
    }

    public static function getOrder($where,$post)
    {
        $order = Order::withSearch(array_keys($where),$where)->paginate(['list_rows'=>5,'query'=>$post]);
        return $order;
    }
}































